using System;
using System.Collections.Generic;
using System.Text;

namespace DejaVuTocReader
{
    public class BitContext
    {
      //~ Instance fields --------------------------------------------------------

      /**
       * The raw value.  Try to use the methods, unless speed is of the essence.
       */
      public byte bit = 0;

      //~ Constructors -----------------------------------------------------------

      /**
       * Creates a new BitContext object.
       */
      public BitContext()
      {
        bit = 0;
      }

      /**
       * Creates a new BitContext object.
       *
       * @param s DOCUMENT ME!
       */
      public BitContext(short s)
      {
        bit = (byte)s;
      }

       public BitContext(byte s)
      {
        bit = s;
      }

      //~ Methods ----------------------------------------------------------------

      /**
       * Query the raw byte value.
       *
       * @return the raw byte value
       */
      public byte byteValue()
      {
        return bit;
      }

      /**
       * Clone this object.
       *
       * @return the newly created clone
       */
      public BitContext clone()
      {
        return new BitContext(bit);
      }

      /**
       * Query the double value.
       *
       * @return (double)intValue()
       */
      public double doubleValue()
      {
        return (double)intValue();
      }

      /**
       * Query the float value.
       *
       * @return (float)intValue()
       */
      public float floatValue()
      {
        return (float)intValue();
      }

      /**
       * Query the integer value.
       *
       * @return the byte value ranged 0 to 255
       */
      public int intValue()
      {
        return 0xff & bit;
      }

      /**
       * Query the long value.
       *
       * @return the byte value ranged 0L to 255L
       */
      public long longValue()
      {
        return 0xff & bit;
      }

      /**
       * Set the byte value.
       *
       * @param value the raw value to set
       */
      public void set(int value)
      {
        bit = (byte)value;
      }

        public void set(BitContext value)
        {
            bit = value.byteValue();
        }

      
      /**
       * Query the short value.
       *
       * @return the byte value ranged 0 to 255
       */
      public short shortValue()
      {
        return (short)(0xff & bit);
      }
    }
}
